<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理员登陆</title>
<link rel="stylesheet" type="text/css" href="../../css/login.css">
</head>
<body>
<div id="wrapper" class="login-page">
<div id="login_form" class="form">
<form class="login-form">
 <h2>管理登录</h2>
<input type="text" placeholder="用户名" value="admin" id="user_name" />
<input type="password" placeholder="密码" id="password" />
<button id="login">登　录</button>
</form>
</div>
</div>
<script src="../../js/jquery-3.1.1.js"></script>
<script src="../../lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/xadmin.js"></script>
<script type="text/javascript">
	function check_login()
	{
	 var name=$("#user_name").val();
	 var pass=$("#password").val();
	 var data={
		"username":name,
		"password":pass
			};
	 $.ajax({
	 	url: "http://www.longm.top:8080/lm/admin/login",
	 	type: "post",
	 	dataType: 'json',
	 	headers:{'Content-Type':'application/json'},
	 	data: JSON.stringify(data),
	 	success: function (result) {
	 		console.log(JSON.stringify(result));
	 		if (result.code === 200) {
				$("#user_name").val("");
				$("#password").val("");
	 			layer.msg("欢迎回来！");
	 			window.localStorage.setItem("token",result.data.token);
				$(location).attr('href', '../admin/admin-index.html');
	 		} else {
	 			$("#login_form").removeClass('shake_effect');
	 			setTimeout(function()
	 			{
	 			 $("#login_form").addClass('shake_effect')
	 			},1);  
	 		}
	 	}
	 });
	}
	$(function(){
		$("#create").click(function(){
			check_register();
			return false;
		})
		$("#login").click(function(){
			check_login();
			return false;
		})
		$('.message a').click(function () {
		    $('form').animate({
		        height: 'toggle',
		        opacity: 'toggle'
		    }, 'slow');
		});
	})
	</script>
</body>
</html>